function onDeletePhotos(url, photosId,namephoto, resp) {
	var isOK = -1;
	
	if(!confirm('Are you sure you want to delete the Photo with Id:' + photosId)) {
		return false;
	}
	$.ajax({
		   type: "POST",
		   url: url,
		   cache: false,
		   data: 'act=delphoto&id=' + photosId+'&name='+namephoto,
		   success: function(msg){
			   var pos=msg.indexOf('<!');
					content=msg.substring(0,pos);
		    	if(content != ""){
		    		obj = jQuery.parseJSON(content);


					if(obj == null) {
						$(resp).innerHTML = 'Something wrong! Reponsed string is: ' + response;
					}
				}
    			isOK = obj.code;
    			$('#'+resp).html(obj.message);
		}
	});
		$('#'+'photos_one_' + photosId).fadeOut(1000, function() {
			// Animation complete.
	  	});
			
}



function onDeleteProduct(url, productId, productImage, resp)
{
	var isOK = -1;
	
	if(!confirm('Are you sure you want to delete the product with Id:' + productId))
	{
		return false;
	}
	$.ajax({
		   type: "POST",
		   url: url,
		   cache: false,
		   data: 'act=delproduct&id=' + productId + '&product_image=' + productImage,
		   success: function(msg){
			   var pos=msg.indexOf('<!');
					content=msg.substring(0,pos);
		    	if(content != ""){
		    		obj = jQuery.parseJSON(content);
	

					if(obj == null)
					{
						$(resp).innerHTML = 'Something wrong! Reponsed string is: ' + response;
					}
				}
				isOK = obj.code;
    			$('#'+resp).html(obj.message);
		}
	});
	$('#'+'product-' + productId).fadeOut(1000, function() {
			// Animation complete.
	  	});
		
}

function onEditProduct(frmID, msgDiv,capa,desc)
{
	
	if($F(type) == 'ajax')
	{
			
		$(capa).value = tinyMCE.getContent(capa);
		$(desc).value = tinyMCE.getContent(desc);
		onEditProductSave(frmID, msgDiv)
		
		return false;
	}
	

	return true;
}
function onAddProductPhotos(frId,inputId) {
	var totalId = document.getElementById(inputId);
	var fraddphotos = document.getElementById(frId);
	var divtag = fraddphotos.getElementsByTagName("tr");
	var newvalue = parseInt(totalId.value) +1 ;
	var tr_head = document.createElement("tr");
		fraddphotos.appendChild(tr_head);				
	var th_head = document.createElement("th");
		th_head.width = "33%";
		th_head.scope = "row";
		th_head.valign = "top";
		th_head.innerHTML = 'Image '+newvalue+':';
		tr_head.appendChild(th_head);	
	var td_head = document.createElement("td");
		td_head.width = "67%";
		tr_head.appendChild(td_head);		
	var file_head = document.createElement("input");
		file_head.type = "file";
		file_head.name = "product_image_"+newvalue;
		td_head.appendChild(file_head);	
		totalId.value = newvalue;
}

function onEditProductSave(frmID, msgDiv)
{
	var newId = '';
	var status = null;
	var ret = null;
	var message = null;
	
	$(frmID).request(
		{
			asynchronous: false,
			parameters: $(frmID).serialize(true),
	  		onComplete: function(transport)
	  		{ 
			  	var response = transport.responseText || "";
			  	var pos=response.indexOf('<!');
				content=response.substring(1,pos);
				
		    	$(msgDiv).innerHTML = '';
		    	if(content != "")
		    	{
		    		obj = content.evalJSON();
		    		if(obj == null)
		    		{
		    			$(msgDiv).update('Something wrong! Reponsed string is: ' + content);
		    		}
		    		
			    	if(msgDiv != null)
				    	$(msgDiv).update(obj.message);
					if(obj.ID==0)
					{
						ret =1;	
						message = obj.msg;
					}
					
		    	}
	  		}
		});
	if(ret==1)
	{
		document.location = '?mod=manage&sub1=product&message=' + message;
	}
	else
	{
	$(msgDiv).style.display = 'block';
	Fat.fade_element(msgDiv, null, 1500, null, null);
	//revent submit page
	}
	return false;
}